function request(method, url) {
    return new Promise((reslove, reject) => {
        let xhr = new XMLHttpRequest();
        xhr.open(method, url);
        xhr.send();
        xhr.onreadystatechange = function () {
            let con = '';
            if (xhr.readyState === 4) {
                let data = JSON.parse(xhr.response)
                //console.log(data);
                reslove(data.hero);
                data.hero.forEach(item => {
                    let li = `<li><a href="https://game.gtimg.cn/images/lol/act/img/js/hero/${item.heroId}}.js"><img src="https://game.gtimg.cn/images/lol/act/img/champion/${item.alias}.png"><p>${item.title}</p></a></li>`
                    con += li;
                })
            }
            document.querySelector('.heros').innerHTML = con;
        }
    })
}
request('get', 'https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js').then((res) => {
    console.log(res);
})

export {
    request
}
//